home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / dev / c / minigl.lha / MiniGL / doc / MiniGL_multitexture.doc < prev    next >
Encoding:
Text File  |  2002-07-01  |  2.7 KB  |  102 lines

  1. 30-06-02 by Christian Michael
  2.  
  3. GL_MGL_ARB_multitexture specification:
  4.  
  5. Special MiniGL implementation whith 1 HW and 1 virtual TMU
  6.  
  7. - Supported texture units: GL_TEXTURE0_ARB, GL_TEXTURE1_ARB
  8. - Supported primitives: GL_POLYGON (more to come)
  9.  
  10. New functions:
  11.  
  12.   glActiveTextureARB (GLenum unit)
  13.   glMultiTexCoord2fARB (GLenum unit, GLfloat s, GLfloat t)
  14.   glMultiTexCoord2fvARB (GLfloat *coord)
  15.  
  16.   mglDrawMultitexBuffer(GLenum BlendSrc, GLenum BlendDst, GLenum TexEnv)
  17.  
  18.  
  19. Significant differences from official GL_ARB_multitexture extension:
  20.  
  21. - Unit1 can only do texmapping if unit0 is active.
  22. - Texture parameters are not unit-speciffic.
  23. - The texture environment for unit1 is completely ignored.
  24.   It has to be specified when the buffer is drawn,
  25.   together with a pair of blend components.
  26. - Texture units are not independant: unit1 has its own
  27.   texture-binding and TEXTURE_2D state, but that's all
  28. - Vertexarrays do not support multitexturing (yet)
  29. - MiniGL buffers all geometry and does not draw anything
  30.   until the following function is called:
  31.  
  32.   mglDrawMultitexBuffer(GLenum BlendSrc, GLenum BlendDst, GLenum TexEnv)
  33.  
  34. NOTE: The current state will be used for unit0.
  35.     Parameters apply to the virtual unit1.
  36.  
  37. The call(s) to this function should generally be delayed as
  38. long as possible since polygons are accumulated in an
  39. internal buffer in order to avoid excessive state changes.
  40.  
  41. This function must be called before certain global
  42. state-changes that could produce undesirable effects.
  43. Examples are texture overwriting, shademodel, zbuffer state.
  44.  
  45.  
  46. Usage:
  47.  
  48. // Enable texture unit 0:
  49.  
  50.     glActiveTextureARB (GL_TEXTURE0_ARB);
  51.     glBindTexture(GL_TEXTURE_2D, solidtexture);
  52.     glEnable (GL_TEXTURE_2D);
  53.     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  54.  
  55. // Enable texture unit 1:
  56.  
  57.     glActiveTextureARB (GL_TEXTURE1_ARB);
  58.     glBindTexture(GL_TEXTURE_2D, alphatexture);
  59.     glEnable (GL_TEXTURE_2D);
  60.     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //ignored by MiniGL implementation
  61.  
  62.     glShadeModel(GL_FLAT);
  63.  
  64.     glColor4f(1,1,1,1);
  65.  
  66. // Draw a multitextured polygon:
  67.  
  68.     float *v = poly->verts[0];
  69.  
  70.     glBegin(GL_POLYGON);
  71.  
  72.     for(i=0; i<poly->numverts; i++, v+=stride)
  73.     {
  74.       glMultiTexCoord2fARB (GL_TEXTURE0_ARB, v[3], v[4]); 
  75.       glMultiTexCoord2fARB (GL_TEXTURE1_ARB, v[5], v[6]); 
  76.       glVertex3f (v[0], v[1], v[2]);
  77.     }
  78.  
  79.     glEnd();
  80.  
  81. // Draw some more polys here.....
  82.  
  83.  
  84. // Disable multitexturing : (not necessary)
  85.  
  86.     glDisable(GL_TEXTURE_2D); //unit 1 was active
  87.  
  88.     glActiveTextureARB (GL_TEXTURE0_ARB);
  89.  
  90.  
  91. // MiniGL implementation-speciffic function call:
  92. // This is NOT part of the official
  93. // GL_ARB_multixture extension
  94. // Note that texture-unit 0 must be active
  95.  
  96.     mglDrawMultitexBuffer (GL_ONE, GL_SRC_COLOR, GL_MODULATE);
  97.  
  98. // Now it is safe to change certain global states:
  99.  
  100.  
  101.  
  102.